package cn.tedu.weibo.controller;

import cn.tedu.weibo.commom.response.JsonResult;
import cn.tedu.weibo.commom.response.StatusCode;
import cn.tedu.weibo.mapper.UserMapper2;
import cn.tedu.weibo.pojo.dto.UserLogonDTO;
import cn.tedu.weibo.pojo.dto.UserRegDTO;
import cn.tedu.weibo.pojo.entity.User;
import cn.tedu.weibo.pojo.vo.UserVO;
import cn.tedu.weibo.service.IUerService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping("/v1/users/")
public class UserController2 {
    @Autowired
    IUerService uerService;
//    注册功能
    @PostMapping("reg")
    public JsonResult reg(@RequestBody UserRegDTO userRegDTO){
        uerService.reg(userRegDTO);
        return JsonResult.ok();
    }
//    登录功能
    @PostMapping("login")
    public JsonResult login(@RequestBody UserLogonDTO userLogonDTO){
        UserVO login = uerService.login(userLogonDTO);
        //把登录成功的用户信息响应给客户端
        return JsonResult.ok(login);
    }
}
